<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2020 All rights reserved.
// +----------------------------------------------------------------------
// | User: Simony <1362229026@qq.com>
// | wechat: Shen86579595
// +----------------------------------------------------------------------

namespace app\common\logic\member;

use \think\Db;
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;

class MemberLogic
{
    protected $function_alias_list = [ //方法别名
        //'alias'=>'真实方法名'   //getMemberListByType 方法名后面加类型值
        'getMemberListByType1' => 'getMemberListByNearby', //附近
        'getMemberListByType2' => 'getMemberListByNewReg', //新注册
        'getMemberListByType3' => 'getMemberListByVideoVerify', //女神  （视频认证通过）
    ];

    /**
     * User: Simony
     * Function:通过类型获取用户列表
     * @param $current_member_id 当前登录用户
     * @param $area_id 城市id
     * @param $categroy 分类 1、附近 2、新注册 3、女神 4、关注
     * @param $show_type 查看类型  -1、所有、1、男 2、女
     * @param $is_online 是否在线
     * @param $level -1全部 0普通会员 1认证等级 2VIP
     * @param $page_size
     * @return array
     */
    public function getMemberListByType($current_member_id, $area_id, $categroy, $show_type, $is_online, $level, $page_size)
    {
        //3个方法类似，之所有起三个方法，是怕后期改动
        $function_alias = __FUNCTION__ . $categroy;
        if (isset($this->function_alias_list[$function_alias])) {
            $real_function = $this->function_alias_list[$function_alias];
            return method_exists($this, $real_function) ? $this->$real_function($current_member_id, $area_id, $show_type, $is_online, $level, $page_size) : [];
        } else {
            return ds_arr(ERROR, '类型有误');
        }
    }

    /**
     * User: Simony
     * Function:附近列表
     * @param $current_member_id 当前登录用户
     * @param $area_id 城市id
     * @param $show_type 查看类型  -1、所有、1、男 2、女
     * @param $is_online 是否在线
     * @param $level -1全部 0普通会员 1认证等级 2VIP
     * @param $page_size
     * @return array
     */
    public function getMemberListByNearby($current_member_id, $area_id, $show_type, $is_online, $level, $page_size)
    {
        //model
        $memberModel = model('common/member/Member');
        $field = "m_t.generation_time,m.sex,m.album_auth,m.avatar,m.id,m.nickname,m.real_verify,m.video_verify,m.birthday,m.profession,m.create_time,m.level"; //

        $where = [];

        if ($area_id > 0) $where[] = ['m.city', 'eq', $area_id];
        if ($show_type != -1) $where[] = ['m.sex', 'eq', $show_type];
        if ($level >= 0) $where[] = ['m.level', 'eq', $level];


        if ($show_type != -1) $where[] = ['m.sex', 'eq', $show_type];

        $order = 'distance asc';
        if ($is_online == 1) $order = 'm_t.generation_time desc,' . $order;

        $memberModel->getMemberListByType($current_member_id, $where, $page_size, $field, $order);
        $res = $memberModel->page_info->toArray();
        if (isset($res['data'])) {
            foreach ($res['data'] as &$v) {
                $v['generation_time'] = empty($v['generation_time']) ? $v['create_time'] : $v['generation_time'];
                $v['url'] = [];
                if (isset($v['file'])) {
                    $v['url_num'] = count($v['file']);
                    if (in_array($v['album_auth'], [1, 2, 3])) $v['file'] = [];
                    foreach ($v['file'] as $key => $value) {
                        if ($value['type'] == 1) $v['url'][] = $value['url'];
                    }
                }
                unset($v['file']);
            }
        }
        return ds_arr(SUCCESS, '获取成功', $res);
    }

    /**
     * User:Simony
     * Function:获取最新注册会员列表
     * @param $current_member_id 当前登录用户
     * @param $area_id 城市id
     * @param $show_type 查看类型  -1、所有、1、男 2、女
     * @param $is_online 是否在线
     * @param $level -1全部 0普通会员 1认证等级 2VIP
     * @param $page_size
     * @return array
     */
    public function getMemberListByNewReg($current_member_id, $area_id, $show_type, $is_online, $level, $page_size)
    {
        $where = [];

        //where
        if ($area_id > 0) $where[] = ['m.city', 'eq', $area_id];
        if ($show_type != -1) $where[] = ['m.sex', 'eq', $show_type];
        if ($level >= 0) $where[] = ['m.level', 'eq', $level];

        //whereOr

        //model
        $memberModel = model('common/member/Member');
        $field = "m_t.generation_time,m.album_auth,m.avatar,m.id,m.nickname,m.real_verify,m.video_verify,m.birthday,m.profession,m.create_time,m.level"; //

        $order = 'm.create_time desc,distance asc';
        if ($is_online == 1) $order = 'm_t.generation_time desc,' . $order;

        $memberModel->getMemberListByType($current_member_id, $where, $page_size, $field, $order);
        $res = $memberModel->page_info->toArray();
        if (isset($res['data'])) {
            foreach ($res['data'] as &$v) {
                $v['generation_time'] = empty($v['generation_time']) ? $v['create_time'] : $v['generation_time'];
                $v['url'] = [];
                if (isset($v['file'])) {
                    $v['url_num'] = count($v['file']);
                    if (in_array($v['album_auth'], [1, 2, 3])) $v['file'] = [];
                    foreach ($v['file'] as $key => $value) {
                        if ($value['type'] == 1) $v['url'][] = $value['url'];
                    }
                }
                unset($v['file']);
            }
        }
        return ds_arr(SUCCESS, '获取成功', $res);

    }

    /**
     * User:Simony
     * Function:获取女神  （视频认证通过）
     * @param $current_member_id 当前登录用户
     * @param $area_id 城市id
     * @param $show_type 查看类型  -1、所有、1、男 2、女
     * @param $is_online 是否在线
     * @param $level -1全部 0普通会员 1认证等级 2VIP
     * @param $page_size
     * @return array
     */
    public function getMemberListByVideoVerify($current_member_id, $area_id, $show_type, $is_online, $level, $page_size)
    {

        $where = [];

        //where
        if ($area_id > 0) $where[] = ['m.city', 'eq', $area_id];
        $where[] = ['m.sex', 'eq', 2]; //$show_type = 2
        $where[] = ['m.video_verify', 'eq', 1];
        if ($level >= 0) $where[] = ['m.level', 'eq', $level];
        //model
        $memberModel = model('common/member/Member');

        $field = "m_t.generation_time,m.album_auth,m.avatar,m.id,m.nickname,m.real_verify,m.video_verify,m.birthday,m.profession,m.create_time,m.level";
        $order = 'distance asc';
        if ($is_online == 1) $order = 'm_t.generation_time desc,' . $order;

        $memberModel->getMemberListByType($current_member_id, $where, $page_size, $field, $order);
        $res = $memberModel->page_info->toArray();
        if (isset($res['data'])) {
            foreach ($res['data'] as &$v) {
                $v['generation_time'] = empty($v['generation_time']) ? $v['create_time'] : $v['generation_time'];
                $v['url'] = [];
                if (isset($v['file'])) {
                    $v['url_num'] = count($v['file']);
                    if (in_array($v['album_auth'], [1, 2, 3])) $v['file'] = [];
                    foreach ($v['file'] as $key => $value) {
                        if ($value['type'] == 1) $v['url'][] = $value['url'];
                    }
                }
                unset($v['file']);
            }
        }
        return ds_arr(SUCCESS, '获取成功', $res);
    }


    /**
     * User:Simony
     * Function:获取关注列表
     * @param $member_id
     * @param $page_size
     */
    public function getMemberListByFollow($current_member_id, $page_size)
    {
        $field = "m_t.generation_time,m.album_auth,m.avatar,m.id,m.sex,m.nickname,m.real_verify,m.video_verify,m.birthday,m.profession,m.create_time,m.level";
        $memberModel = model('common/member/Member');
        $memberModel->followList($current_member_id, $page_size, $field);
        $res = $memberModel->page_info->toArray();
        if (isset($res['data'])) {
            foreach ($res['data'] as &$v) {
                $v['generation_time'] = empty($v['generation_time']) ? $v['create_time'] : $v['generation_time'];
                $v['url'] = [];
                if (isset($v['file'])) {
                    $v['url_num'] = count($v['file']);
                    if (in_array($v['album_auth'], [1, 2, 3])) $v['file'] = [];
                    foreach ($v['file'] as $key => $value) {
                        if ($value['type'] == 1) $v['url'][] = $value['url'];
                    }
                }
                unset($v['file']);
            }
        }
        return ds_arr(SUCCESS, '获取成功', $res);
    }

    /**
     * User:Simony
     * Function:
     * @param $member_id
     * @param $been_member_id
     * @param int $type 类型 0:取消关注，1：关注 2：拉黑
     * @param int $status 状态 1：启用 0：停用
     * @return array
     */
    public function follow($member_id, $been_member_id, $type = 1, $status = 1)
    {
        if ($member_id == $been_member_id) return ds_arr(ERROR, '非法操作，自己对自己操作');

        //model
        $memberModel = model('common/member/Member');
        $followBlacklistModel = model('common/member/FollowBlacklist');

        $member = $memberModel->getInfoByID($member_id);
        if (empty($member)) return ds_arr(ERROR, '会员不存在');
        $been_member = $memberModel->getInfoByID($been_member_id);
        if (empty($been_member)) return ds_arr(ERROR, '被关注用户不存在');


        if ($type == 0) {
            $res = $followBlacklistModel->del(['member_id' => $member_id, 'been_member_id' => $been_member_id]);
            return $res ? ds_arr(SUCCESS, '操作成功', ['id' => $res]) : ds_arr(ERROR, '操作失败');
        }
        $data = [
            'member_id' => $member_id,
            'been_member_id' => $been_member_id,
            'type' => $type,
            'status' => 1
        ];

        $follow_black = $followBlacklistModel->getInfo(['member_id' => $member_id, 'been_member_id' => $been_member_id]);
        if ($follow_black) {
            if ($follow_black['type'] == $type) return ds_arr(ERROR, '请勿重复操作');
            $res = $followBlacklistModel->editByID($follow_black['id'], $data);
        } else {
            if ($type == 0) return ds_arr(ERROR, '请勿重复操作');
            $res = $followBlacklistModel->add($data);
        }
        return $res ? ds_arr(SUCCESS, '操作成功') : ds_arr(ERROR, '操作失败');
    }

    /**
     * User:Simony
     * Function:
     * @param $member_id
     * @param $album_auth 0为公开;1为付费查看;2为验证查看;3为隐身
     * @param int $album_price
     * @return array
     */
    public function setAlbumAuth($member_id, $album_auth, $album_price = 0)
    {
        //model
        $memberModel = model('common/member/Member');
        $member = $memberModel->getInfoByID($member_id, 'album_auth,album_price');

        //judge
        if (empty($member)) return ds_arr(ERROR, '会员不存在');
        if (!in_array($album_auth, [0, 1, 2, 3])) return ds_arr(ERROR, '权限参数有误');
        if ($album_auth == 1) {
            if ($member['album_auth'] == $album_auth && $member['album_price'] == $album_price) return ds_arr(ERROR, '请勿重复操作');
            if (floatval($album_price) <= floatval(0)) return ds_arr(ERROR, '付费查看金额不能小于等于0');
        } else {
            $album_price = 0;
            if ($member['album_auth'] == $album_auth) return ds_arr(ERROR, '请勿重复操作');
        }

        $data = [
            'album_auth' => $album_auth,
            'album_price' => $album_price,
        ];

        $res = $memberModel->editByID($member_id, $data);
        return $res ? ds_arr(SUCCESS, '设置成功') : ds_arr(ERROR, '设置失败');
    }


    /**
     * User:Simony
     * Function:举报会员
     * @param $member_id
     * @param $content_id
     * @param $desc
     * @param $type_id
     * @return array
     */
    public function reportMember($member_id, $report_member_id, $type_id, $desc)
    {

        if ($member_id == $report_member_id) return ds_arr(ERROR, '自己不能举报自己');
        $report_type = model('common/report/ReportType')->getInfoById($type_id);

        if (empty($report_type)) return ds_arr(ERROR, '举报类型不存在');

        $data = [
            'member_id' => $member_id,
            'report_member_id' => $report_member_id,
            'type_id' => $type_id,
            'desc' => $desc,
            'state' => 0,
            'category' => 2,
            'create_time' => time()
        ];

        $reportModel = model('common/report/ReportUser');
        $content = $reportModel->getInfo(['member_id' => $member_id, 'report_member_id' => $report_member_id, 'category' => 2]);
        if ($content) return ds_arr(ERROR, '请勿重复举报');

        $res = $reportModel->add($data);
        return $res ? ds_arr(SUCCESS, '举报成功', ['id' => $res]) : ds_arr(ERROR, '举报失败');
    }


    /**
     * User:Simony
     * Function: 显示用户
     * @param $show_member_id
     */
    public function getMemberBaseInfo($member_id, $been_member_id)
    {
        //model
        $memberModel = model('common/member/Member');
        $member = $memberModel->getInfoByID($member_id);
        $field = 'm.level,m.id,m.sex,m.avatar,m.nickname,a.name as city,m.real_verify,m.profession,m.birthday,m.height,m.weight,m.content_types,m.expect_object,m.wechat,m.wechat_hide';
        $been_member = $memberModel->getMemberInfo($been_member_id, $field);
        if (empty($been_member)) return ds_arr(ERROR, '查看的会员不存在');

        if ($member['sex'] == $been_member['sex']) return ds_arr(ERROR, '同性之间不能互相查看');
        if ($member_id != $been_member_id && $been_member['wechat_hide'] == 1) $been_member['wechat'] = '已隐藏';

        $birthday = $memberModel->birthday($been_member['birthday']);
        $been_member['age_constellation'] = $birthday['age'] . '岁·' . $birthday['constellation'];

        //校验
        $authLogic = model('common/AuthLogic', 'logic');
        $levelModel = model('common/member/Level');
        $viewLogic = model('common/view/ViewLogLogic', 'logic');


        $is_expire = $authLogic->isExpire($member_id, $been_member_id, 1); //会员信息

        $been_member['show_member_level'] = $member['level'];
        $been_member['self_real_verify'] = $member['real_verify'];


        if ($is_expire == true) {  //已失效 //添加记录
            $surplus_num = $authLogic->getDaySurplusViewNum($member_id, $levelModel::VIEW_MEMBER_NUM);
            if (isset($surplus_num['code']) && $surplus_num['code'] == ERROR) return ds_arr($surplus_num['code'], $surplus_num['msg'], $surplus_num['result']);
            if ($surplus_num == 0) return ds_arr(ERROR, '今日查看会员信息次数已用光', ['show_member_level' => $been_member['show_member_level'], 'self_real_verify' => $been_member['self_real_verify']]);
            $res = $viewLogic->addViewLog($member_id, $been_member_id, $levelModel::VIEW_MEMBER_EFFECTIVE_TIME);
            if ($res['code'] != SUCCESS) return ds_arr($res['code'], $res['msg'], $res['result']);
        }

        $been_member['is_click'] = 0;

        $is_expire = $authLogic->isExpire($member_id, $been_member_id, 2); //社交信息
        if ($is_expire == true) {
            $been_member['wechat'] = '*******';
            $been_member['is_click'] = 1;
        }
        if ($been_member['wechat_hide'] == 1) $been_member['is_click'] = 0;

        //是否存在正在进行的节目
        $contentModel = model('common/content/Content');
        $where = [
            ['member_id', 'eq', $been_member_id],
            ['type', 'eq', 2],//节目是2
            ['end_date', 'gt', time()],
        ];

        $been_member['run_program'] = $contentModel->getInfo($where) ? 1 : 0;


        //是否已评价
        $evaluateLogModel = model('common/evaluate/EvaluateLog');
        $isEvaluate = $evaluateLogModel->isEvaluate($member_id, $been_member_id);

        $been_member['is_evaluate'] = $isEvaluate ? 1 : 0;

        $been_member['dynamic_num'] = $contentModel->getCount(['type' => 1, 'member_id' => $been_member_id]);
        $type_where = [1, 2, 3];
        if ($been_member['real_verify'] == 1) $type_where[] = 7;
        $been_member['album_num'] = model('common/member/File')->getCount(['member_id' => $been_member_id, 'type' => $type_where,'status'=>1]);


        $use_auth_res = $authLogic->isUseAuth($member_id, true); //校验使用权限
        $required_real_verify = $use_auth_res === true ? 0 : 1;
        $been_member['required_real_verify'] = $required_real_verify == 1 && $been_member['is_click'] == 1 ? 1 : 0;
        // 增加可用余额返回
        $been_member['self_balance'] = $member['available_balance'];
        return ds_arr(SUCCESS, '获取成功', $been_member);
    }


    /**
     * User: Simony
     * Function: 查看社交账户
     */
    public function viewSocialAccount($member_id, $been_member_id)
    {
        //model
        $memberModel = model('common/member/Member');

        $field = 'm.id,m.avatar,m.nickname,a.name as city,m.real_verify,m.video_verify,m.birthday,m.height,m.weight,m.content_types,m.expect_object,m.wechat,m.wechat_hide';
        $been_member = $memberModel->getMemberInfo($been_member_id, $field);

        if (empty($been_member)) return ds_arr(ERROR, '查看的会员不存在');
        if ($member_id != $been_member_id && $been_member['wechat_hide'] == 1) $been_member['wechat'] = '已隐藏';

        $data = [];
        $data['wechat'] = $been_member['wechat'];

        $authLogic = model('common/AuthLogic', 'logic');
        $levelModel = model('common/member/Level');
        $viewLogic = model('common/view/ViewLogLogic', 'logic');
        $is_expire = $authLogic->isExpire($member_id, $been_member_id, 2); //社交信息
        $surplus_num = $authLogic->getDaySurplusViewNum($member_id, $levelModel::DAY_VIEW_MEMBER_SOCIAL_ACCOUNT_NUM);
        if (isset($surplus_num['code']) && $surplus_num['code'] == ERROR) return ds_arr($surplus_num['code'], $surplus_num['msg'], $surplus_num['result']);
        if ($is_expire == true) { //已失效 //添加记录
            if ($surplus_num == 0) {
                $data['direct_view'] = 3; //付费查看
                if ($data['direct_view'] != 1) $data['wechat'] = '*******';
            } else {
                $res = $viewLogic->addViewLog($member_id, $been_member_id, $levelModel::DAY_VIEW_MEMBER_SOCIAL_ACCOUNT_EFFECTIVE_TIME);
                if ($res['code'] != SUCCESS) return ds_arr($res['code'], $res['msg'], $res['result']);
                $data['direct_view'] = 2; //次数查看

            }
        } else {
            $data['direct_view'] = 1; //直接查看
        }
        $data['surplus_num'] = $surplus_num; //次数查看
        return ds_arr(SUCCESS, '获取成功', $data);

    }

    /**
     * User:Simony
     * Function:更新用户经纬度
     * @param $member_id
     * @param $lng
     * @param $lat
     * @return array
     */
    public function updateLngLat($member_id, $lng, $lat)
    {
        $memberModel = model('common/member/Member');

        $member = $memberModel->getInfoByID($member_id, 'longitude,latitude');

        if ($member['longitude'] == $lng && $member['latitude'] == $lat) return ds_arr(SUCCESS, '无需重复修改经纬度');//返回成功

        //更新 member lat lng
        $update_data = [
            'longitude' => $lng,
            'latitude' => $lat,
            'long_lat_geometry' => Db::raw("geomfromtext('POINT({$lng} {$lat})')")
        ];
        $res = $memberModel->editByID($member_id, $update_data);
        return $res ? ds_arr(SUCCESS, '更新经纬度成功') : ds_arr(ERROR, '经纬度更新失败');
    }

    /**
     * User:Simony
     * Function: 个人中心
     * @param $member_id
     */
    public function personalCenter($member_id)
    {
        //model
        $memberModel = model('common/member/Member');
        $followBlacklistModel = model('common/member/FollowBlacklist');

        //用户信息
        $field = "id,avatar,sex,nickname,real_verify,video_verify,birthday,profession,available_balance,unissued_balance,album_auth,invite_code,level,identity";
        $member = $memberModel->getInfoByID($member_id, $field);
        if (empty($member)) return ds_arr(ERROR, '用户不存在');
        $member['balance'] = $member['available_balance'] + $member['unissued_balance'];

        //星座年龄
        if (empty($member['birthday'])) $member['birthday'] = '1970-01-01';
        $birthday = $memberModel->birthday($member['birthday']);
        $member['age'] = $birthday['age'] . '岁';
        $member['constellation'] = $birthday['constellation'];

        //关注数
        $member['follow_num'] = $followBlacklistModel->getCount(['member_id' => $member_id, 'type' => 1, 'status' => 1]);

        //评价数
        $evaluateLogModel = model('common/evaluate/EvaluateLog');
        $evaluate_member_ids_arr = $evaluateLogModel->getCol('evaluate_member_ids', ['been_member_id' => $member_id]);
        $member['evaluate_num'] = 0;
        foreach ($evaluate_member_ids_arr as $v) {
            $member['evaluate_num'] += count(explode(',', $v));
        }

        //相册
        $fileModel = model('common/member/File');
        $type_where = [1, 2, 3];
        if ($member['real_verify'] == 1) $type_where[] = 7;
        $member['album'] = $fileModel->getList(['member_id' => $member_id, 'type' => $type_where], 0, 'id,type,url,is_oneself');
        $member['album_num'] = count($member['album']);

        //统计阅后即焚人数
        $photoPayModel = model('common/photo/Pay');
        $member['read_burn_num'] = $photoPayModel->getCount(['view_member_id' => $member_id, 'type' => 3]);


        $packageBuyLogModel = model('common/package/PackageBuyLog');
        $member['package_expire_time'] = $packageBuyLogModel->getMax(['member_id' => $member_id], 'expire_end_time'); //最大失效时间
        return ds_arr(SUCCESS, '获取成功', $member);
    }


    /**
     * User:Simony
     * Function: 会员查看相册
     * @param $member_id
     * @param $show_member_id
     */
    public function memberAblum($member_id, $been_member_id)
    {
        $memberModel = model('common/member/Member');
        $member = $memberModel->getInfoByID($member_id);

        $login_member_level = $member['level'];
        $been_member = $memberModel->getMemberInfo($been_member_id);
        if (empty($been_member)) return ds_arr(ERROR, '查看的会员不存在');


        //获取照片相关
        $fileModel = model('common/member/File');
        $type_where = [1, 2, 3,7];
        if ($been_member['real_verify'] == 1) $type_where[] = 7;
        $where = [
            'f.member_id' => $been_member_id,
            'f.type' =>$type_where, //文件类型 1：照片、2：阅后即焚、3：红包照片,7认证照片
//            'f.status' => 1,
        ];
        if($member_id!=$been_member_id) $where['f.status'] = 1;
        $field = 'f.id,f.type,f.status,f.is_oneself,f.url,f.red_packet_price,p_p.file_id,p_p.expire_time';
        $file = $fileModel->getMemberAblum($member_id, $been_member_id, $where, $field, 'f.id desc',0);
        $file_count = count($file);


        $authLogic = model('common/AuthLogic', 'logic');
        $levelModel = model('common/member/Level');

        $level_auth = moduleConfig('level_auth');
        $read_after_burn = $level_auth[$levelModel::READ_AFTER_BURN][$member['sex']][$member['level']] ?? 0;
        $vip_read_after_burn = $level_auth[$levelModel::READ_AFTER_BURN][1][2] ?? 0;
        $surplus_num = $authLogic->getDaySurplusViewNum($member_id, $levelModel::DAY_VIEW_MEMBER_ALBUM_NUM);
        $direct_view = 1;
        if ($been_member['album_auth'] == 1) { //1为付费相册查看
            $is_expire = $authLogic->isExpire($member_id, $been_member_id, 3); //相册信息  查看类型：1，会员信息 2微信+聊天社交 3,相册

            if ($is_expire == true) {  //已失效 //添加记录
                if (isset($surplus_num['code']) && $surplus_num['code'] == ERROR) return ds_arr($surplus_num['code'], $surplus_num['msg'], $surplus_num['result']);

                if ($surplus_num == 0) {
                    $direct_view = 3; //付费查看
                } else {
                    $direct_view = 2; //次数查看
                }
            }
            //付费查看时的显示
            if ($direct_view == 2 || $direct_view == 3) {
                $data = [
                    'album_auth' => $been_member['album_auth'],
                    'album_price' => $been_member['album_price'],
                    'surplus_num' => $surplus_num,
                    'read_after_burn' => $read_after_burn,
                    'vip_read_after_burn' => $vip_read_after_burn,
                    'direct_view' => $direct_view,
                    'count' => $file_count,
                    'list' => [],
                ];
                $data['login_member_level'] = $login_member_level;
                return ds_arr(SUCCESS, '获取成功', $data);

            }
        } elseif ($been_member['album_auth'] == 3) {
            $data = [
                'album_auth' => $been_member['album_auth'],
                'album_price' => $been_member['album_price'],
                'surplus_num' => $surplus_num,
                'read_after_burn' => $read_after_burn,
                'vip_read_after_burn' => $vip_read_after_burn,
                'direct_view' => 1,
                'count' => $file_count,
                'list' => [],
            ];
            $data['login_member_level'] = $login_member_level;
            return ds_arr(SUCCESS, '获取成功', $data);
        }


        if ($member_id != $been_member_id) {
            $imageBlurLogic = model('common/ImageBlur', 'logic');
            $fileLogic = model('common/file/FileLogic', 'logic');
            foreach ($file as &$v) {
                $v['direct_view'] = 1; //直接查看默认

                if ($v['type'] == 2) { //阅后即焚图片处理
                    if (!is_null($v['file_id'])) {//已阅
                        $v['url'] = config('app.fixed_image_path.read_burn');
                    } else { //未阅
                        $v['direct_view'] = 2; //间接查看
                        $file_info = $fileLogic->getFileInfo($v['url']);
                        $save_filename = md5($file_info['relative_file_path']) . "." . $file_info['extension']; //新的文件名
                        if($fileLogic->fileExists($file_info['relative_file_path']) && !$fileLogic->fileExists($file_info['relative_dir_path'].DS.$save_filename)){
                             $res=$imageBlurLogic->gaussian_blur($file_info['real_file_path'], $file_info['real_dir_path'], $save_filename);
                        }
                        $v['url'] =$file_info['relative_dir_path'] . DS . $save_filename;

                    }
                } elseif ($v['type'] == 3) {
                    if (
                        is_null($v['expire_time'])  //找不到过期
                        ||
                        ($v['expire_time'] > 0 && $v['expire_time'] < time()) //大于0，并且有效期小于当前时间
                    ) {
                        $v['direct_view'] = 2; //间接查看
                        $file_info = $fileLogic->getFileInfo($v['url']);
                        $save_filename = md5($file_info['relative_file_path']) . "." . $file_info['extension']; //新的文件名
                        if($fileLogic->fileExists($file_info['relative_file_path']) && !$fileLogic->fileExists($file_info['relative_dir_path'].DS.$save_filename)){
                             $res=$imageBlurLogic->gaussian_blur($file_info['real_file_path'], $file_info['real_dir_path'], $save_filename);
                        }
                        $v['url'] =$file_info['relative_dir_path'] . DS . $save_filename;

                    }
                }

            }
        }


        $data = [
            'album_auth' => $been_member['album_auth'],
            'album_price' => $been_member['album_price'],
            'surplus_num' => $surplus_num,
            'direct_view' => $direct_view,
            'read_after_burn' => $read_after_burn,
            'vip_read_after_burn' => $vip_read_after_burn,
            'count' => $file_count,
            'list' => $file,
        ];
        $data['login_member_level'] = $login_member_level;

        return ds_arr(SUCCESS, '获取成功', $data);
    }


    /**
     * User:Simony
     * Function:评价列表
     * @param $member_id
     */
    public function getEvaluateTypeList($member_id)
    {
        $memberModel = model('common/member/Member');
        $evaluateTypeModel = model('common/evaluate/EvaluateType');
        $evaluateLogModel = model('common/evaluate/EvaluateLog');

        $sex = $memberModel->getValByID($member_id, 'sex'); //1男性;2女性;3公共',
        $type = [3];
        if ($sex > 0) $type[] = $sex;
        $where = [
            'type' => $type,
            'is_show' => 1
        ];


        $type_list = $evaluateTypeModel->getList($where, 0, 'id,name', 'des desc');
        $evaluateLog_list = $evaluateLogModel->getCol('type,evaluate_member_ids', ['been_member_id' => $member_id]);
        foreach ($type_list as &$v) {
            $v['num'] = 0;
            if (empty($evaluateLog_list)) continue;
            $type_id = $v['id'];
            if (isset($evaluateLog_list[$type_id])) {
                $evaluate_member_ids_arr = explode(',', $evaluateLog_list[$v['id']]);
                $v['num'] = count($evaluate_member_ids_arr);
            }
        }

        $data = $type_list;

        return ds_arr(SUCCESS, '获取成功', $data);
    }


    /**
     * User: Simony
     * Function: 付费查看社交账号
     * @param $member_id
     * @param $been_member_id
     * @return array
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function payViewSocialAccount($member_id, $been_member_id)
    {
        $memberModel = model('common/member/Member');

        $field = 'm.id,m.avatar,m.username,m.nickname,a.name as city,m.real_verify,m.video_verify,m.birthday,m.height,m.weight,m.content_types,m.expect_object,m.wechat,m.wechat_hide';
        $been_member = $memberModel->getMemberInfo($been_member_id, $field);
        if (empty($been_member)) return ds_arr(ERROR, '查看的会员不存在');
        $member = $memberModel->getMemberInfo($member_id);
        if (empty($member)) return ds_arr(ERROR, '会员不存在');


        $levelModel = model('common/member/Level');
        $viewLogic = model('common/view/ViewLogLogic', 'logic');
        $authLogic = model('common/AuthLogic', 'logic');

        $use_auth_res = $authLogic->isUseAuth($member_id, true); //校验使用权限
        if (isset($use_auth_res['code']) && $use_auth_res['code'] != SUCCESS) return ds_arr($use_auth_res['code'], $use_auth_res['msg'], $use_auth_res['result']);

        $is_expire = $authLogic->isExpire($member_id, $been_member_id, 2); //社交信息
        if ($is_expire == true) { //已失效 //添加记录
            $surplus_num = $authLogic->getDaySurplusViewNum($member_id, $levelModel::DAY_VIEW_MEMBER_SOCIAL_ACCOUNT_NUM);
            if (isset($surplus_num['code']) && $surplus_num['code'] == ERROR) return ds_arr($surplus_num['code'], $surplus_num['msg'], $surplus_num['result']);
            if ($surplus_num == 0) {
                //付费
                $cost = moduleConfig('cost');
                $price = isset($cost['social_account_cost']) && $cost['social_account_cost'] > 0 ? $cost['social_account_cost'] : 0;

                if (floatval($member['available_balance']) < floatval($price)) return ds_arr(JUMP_RECHARGE, '余额不足，还差' . ($price - $member['available_balance']) . '金币,请及时充值');

                //添加付费查看日志
                $res = $viewLogic->addViewLog($member_id, $been_member_id, $levelModel::DAY_VIEW_MEMBER_SOCIAL_ACCOUNT_EFFECTIVE_TIME, $price);
                if ($res['code'] != SUCCESS) return ds_arr($res['code'], $res['msg'], $res['result']);

                //更新用户余额
                $desc = '付费查看' . $been_member['username'] . '社交账户';
                $update_available_balance_res = $this->updateAvailableBalance($member_id, -$price, 0, 0, $desc);
                if ($update_available_balance_res['code'] != SUCCESS) return ds_arr($update_available_balance_res['code'], $update_available_balance_res['msg']);

                return ds_arr(SUCCESS, '付费成功');

            } else {
                return ds_arr(ERROR, '你还有次数可以使用，无效付费');
            }
        } else {
            return ds_arr(ERROR, '当前用户已查看过，未过期可以直接进入查看');
        }
    }

    /***
     * User: Simony
     * Function:更新用户余额 （添加余额变更记录）
     * @param $member_id
     * @param $price 金额
     * @param $pay_type 0余额支付 1微信支付 2支付宝支付
     * @param $op_type 操作类型 0购买 1充值 2提现 3扣款，4收益类
     * @param $desc 描述
     * @return array
     */
    public function updateAvailableBalance($member_id, $price, $pay_type, $op_type, $desc, $flag_id = 0)
    {
        //余额变更记录
        $add_blance_log_data = [
            'member_id' => $member_id,
            'desc' => $desc,
            'money' => $price,
            'pay_type' => $pay_type,  //0余额支付
            'op_type' => $op_type, // 0其他 1 余额充值
            'create_time' => time(),
            'flag_id' => $flag_id,
        ];
        $add_blance_log_res = model('common/member/BlanceLog')->add($add_blance_log_data);
        if (!$add_blance_log_res) return ds_arr(ERROR, '添加余额记录失败');

        //会员数据
        $update_member_data = [
            'available_balance' => Db::raw('available_balance+' . $price),
        ];

        $update_member_data = model('common/member/Member')->edit(['id' => $member_id], $update_member_data);
        if (!$update_member_data) return ds_arr(ERROR, '余额更新失败');
        return ds_arr(SUCCESS, '更新成功');
    }


    /**
     * User: Simony
     * Function: 阅后即焚
     * @param $member_id
     * @param $file_id
     */
    public function readBurn($member_id, $file_id)
    {

        $member = model('common/member/Member')->getInfoByID($member_id);
        if (empty($member)) return ds_arr(ERROR, '会员不存在');

        $file = model('common/member/File')->getInfoByID($file_id);
        if (empty($file)) return ds_arr(ERROR, '文件不存在');
        if ($file['type'] != 2) return ds_arr(ERROR, '非阅后即焚文件');

        $data = [
            'type' => 3, //阅后即焚
            'file_id' => $file_id,
            'member_id' => $member_id,
            'view_member_id' => $file['member_id'],
            'expire_time' => 0
        ];

        $res = model('common/photo/Pay')->add($data);

        $res ? $this->api_ajaxReturn(SUCCESS, '操作成功') : $this->api_ajaxReturn(ERROR, '操作失败');
    }


    /**
     * User: Simony
     * Function: 查看相册照片
     * @param $member_id
     * @param $file_id
     * @return array
     */
    public function viewAblumImg($member_id, $file_id)
    {

        $field = "id,type,url,red_packet_price,member_id";
        $file = model('common/member/File')->getInfoByID($file_id, $field);
        if (empty($file)) return ds_arr(ERROR, '文件不存在');

        if ($file['member_id'] != $member_id) {

            switch ($file['type']) { // 1：照片、2：阅后即焚、3：红包照片
                case 1:
                    break;
                case 2:
                    $photoPayModel = model('common/photo/Pay');
                    $imageBlurLogic = model('common/ImageBlur', 'logic');
                    $where = [
                        'member_id' => $member_id,
                        'file_id' => $file_id,
                        'type' => 3, //查看类型 1：相册、2：相片、3：阅后即焚
                    ];
                    $photoPay = $photoPayModel->getInfo($where);

                    if ($photoPay) { //已阅
                        $file_info = $fileLogic->getFileInfo($file['url']);
                        $save_filename = md5($file_info['relative_file_path']) . "." . $file_info['extension']; //新的文件名
                        if($fileLogic->fileExists($file_info['relative_file_path']) && !$fileLogic->fileExists($file_info['relative_dir_path'].DS.$save_filename)){
                             $res=$imageBlurLogic->gaussian_blur($file_info['real_file_path'], $file_info['real_dir_path'], $save_filename);
                        }
                        $file['url'] =$file_info['relative_dir_path'] . DS . $save_filename;                    
                    }
                    break;
                case 3:
                    $photoPayLogic = model('common/photo/PhotoPayLogic', 'logic');
                    $imageBlurLogic = model('common/ImageBlur', 'logic');
                    $viewPhotoIsExpire = $photoPayLogic->viewPhotoIsExpire($member_id, $file_id, 2); //2代表查看相片

                    if ($viewPhotoIsExpire == true) { //过期
                        $file_info = $fileLogic->getFileInfo($file['url']);
                        $save_filename = md5($file_info['relative_file_path']) . "." . $file_info['extension']; //新的文件名
                        if($fileLogic->fileExists($file_info['relative_file_path']) && !$fileLogic->fileExists($file_info['relative_dir_path'].DS.$save_filename)){
                             $res=$imageBlurLogic->gaussian_blur($file_info['real_file_path'], $file_info['real_dir_path'], $save_filename);
                        }
                        $file['url'] =$file_info['relative_dir_path'] . DS . $save_filename;   
                    }
                    break;
                default:
                    return ds_arr(ERROR, '文件非相册图片');
                    break;

            }
        }

        unset($file['member_id']);
        return ds_arr(SUCCESS, '读取成功', $file);

    }


    /**
     * User: Simony
     * Function: 查看相册照片
     * @param $member_id
     * @param $file_id
     * @return array
     */
    public function viewAblumImgList($member_id, $show_member_id)
    {

        $field = "id,type,url,red_packet_price,member_id";

        $file_list = model('common/member/File')->getList(['member_id' => $show_member_id, 'type' => [1, 2, 3]]);

        foreach ($file_list as &$file) {
            if ($file['member_id'] != $member_id) {

                switch ($file['type']) { // 1：照片、2：阅后即焚、3：红包照片
                    case 1:
                        $file['direct_view'] = 1;
                        break;
                    case 2:
                        $photoPayModel = model('common/photo/Pay');
                        $imageBlurLogic = model('common/ImageBlur', 'logic');
                        $where = [
                            'member_id' => $member_id,
                            'file_id' => $file['id'],
                            'type' => 3, //查看类型 1：相册、2：相片、3：阅后即焚
                        ];
                        $photoPay = $photoPayModel->getInfo($where);

                        if ($photoPay) { //已阅
                            $file_info = $fileLogic->getFileInfo($file['url']);
                            $save_filename = md5($file_info['relative_file_path']) . "." . $file_info['extension']; //新的文件名
                            if($fileLogic->fileExists($file_info['relative_file_path']) && !$fileLogic->fileExists($file_info['relative_dir_path'].DS.$save_filename)){
                                 $res=$imageBlurLogic->gaussian_blur($file_info['real_file_path'], $file_info['real_dir_path'], $save_filename);
                            }
                            $file['url'] =$file_info['relative_dir_path'] . DS . $save_filename;
                            $file['direct_view'] = 2;
                        } else {
                            $file['direct_view'] = 1;
                        }
                        break;
                    case 3:
                        $photoPayLogic = model('common/photo/PhotoPayLogic', 'logic');
                        $imageBlurLogic = model('common/ImageBlur', 'logic');
                        $viewPhotoIsExpire = $photoPayLogic->viewPhotoIsExpire($member_id, $file['id'], 2); //2代表查看相片

                        if ($viewPhotoIsExpire == true) { //过期
                            $file_info = $fileLogic->getFileInfo($file['url']);
                            $save_filename = md5($file_info['relative_file_path']) . "." . $file_info['extension']; //新的文件名
                            if($fileLogic->fileExists($file_info['relative_file_path']) && !$fileLogic->fileExists($file_info['relative_dir_path'].DS.$save_filename)){
                                 $res=$imageBlurLogic->gaussian_blur($file_info['real_file_path'], $file_info['real_dir_path'], $save_filename);
                            }
                            $file['url'] =$file_info['relative_dir_path'] . DS . $save_filename;
                            $file['direct_view'] = 2;
                        } else {
                            $file['direct_view'] = 1;
                        }
                        break;
                    default:
                        return ds_arr(ERROR, '文件非相册图片');
                        break;

                }
            }

            unset($file['member_id']);
        }


        return ds_arr(SUCCESS, '读取成功', $file_list);

    }


    /**
     * User:Simony
     * Function:次数解锁相册
     * @param $member_id
     * @param $show_member_id
     */
    public function timesUnlockAlbum($member_id, $been_member_id)
    {
        $memberModel = model('common/member/Member');
        $been_member = $memberModel->getMemberInfo($been_member_id);
        if (empty($been_member)) return ds_arr(ERROR, '查看的会员不存在');

        $authLogic = model('common/AuthLogic', 'logic');
        $levelModel = model('common/member/Level');

        $surplus_num = $authLogic->getDaySurplusViewNum($member_id, $levelModel::DAY_VIEW_MEMBER_ALBUM_NUM);
        if ($been_member['album_auth'] != 1) return ds_arr(ERROR, '非付费相册无需扣除次数');

        //校验
        $viewLogic = model('common/view/ViewLogLogic', 'logic');
        $is_expire = $authLogic->isExpire($member_id, $been_member_id, 3); //相册信息  查看类型：1，会员信息 2微信+聊天社交 3,相册

        if ($is_expire != true) return ds_arr(ERROR, '还在有效期内无需扣除次数');
        if (isset($surplus_num['code']) && $surplus_num['code'] == ERROR) return ds_arr($surplus_num['code'], $surplus_num['msg'], $surplus_num['result']);

        if ($surplus_num == 0) return ds_arr(ERROR, '没有次数，请付费查看');
        $res = $viewLogic->addViewLog($member_id, $been_member_id, $levelModel::DAY_VIEW_MEMBER_ALBUM_EFFECTIVE_TIME);
        if (isset($res['code']) && $res['code'] == ERROR) return ds_arr($res['code'], $res['msg'], $res['result']);

        return ds_arr(SUCCESS, '次数扣除成功');
    }


    /**
     * User: Simony
     * Function:真人认证
     * @param $file_id 留底照片的文件id
     * @param $token 易盾SDK上传给业务服务端的token，唯一标记一次活体检测，有效期20分钟
     */
    public function realNameAuth($member_id, $file_id, $token)
    {
        $fileModel = model('common/member/File');
        $file = $fileModel->getInfo(['member_id' => $member_id, 'id' => $file_id, 'type' => 7, 'status' => 1]);
        if (empty($file)) return ds_arr(ERROR, '留底照片不存在');

        $avatar1 = model('common/file/FileLogic', 'logic')->getRealPath($file['url']); //留底照片

        $yiDunLogic = model('common/YiDunLogic', 'logic');
        $liveperson_res = $yiDunLogic->liveperson($token, "true");
        if ($liveperson_res['code'] != SUCCESS) return ds_arr(ERROR, $liveperson_res['msg']);
        if ($liveperson_res['result']['lpCheckStatus'] != 1) return ds_arr(ERROR, $liveperson_res['result']['reasonType']); //

        $avatar2 = $liveperson_res['result']['avatar']; //活体检测抓取的头像正面照
        $facecompare_res = $yiDunLogic->facecompare($avatar1, $avatar2, 1);
        if ($facecompare_res['code'] != SUCCESS) return ds_arr(ERROR, $facecompare_res['msg']);

        if ($facecompare_res['result']['matched'] == 0) return ds_arr(ERROR, '其他错误');
        if ($facecompare_res['result']['matched'] == 2) return ds_arr(ERROR, '不是同一人');
        if ($facecompare_res['result']['score'] < 0.55) return ds_arr(ERROR, '比对不一致');


        //奖金结算以及方法
        $bonusLogic = model('common/BonusLogic', 'logic');
        $res = $bonusLogic->recommendBonus($member_id);
        if ($res['code'] != SUCCESS) return ds_arr(ERROR, $res['msg']);
        $grant_bonus_res = $bonusLogic->grantBonus(model('common/bonus/Bonus')::SECOND_GRANT); //发放奖金

        //认证
        model('common/member/Member')->editByID($member_id, ['real_verify' => 1]); //认证

        //发送消息
        $noticleLogic = model('common/Noticle', 'logic');
        $levelModel = model('common/member/Level');
        $levelModel::VERIFIY_LEVEL && model('common/Noticle', 'logic')->sendAutoTxt($member_id, $noticleLogic::REAL_VERIFY_NOTICE); //每次低等级升级vip都需要调用

        //赠送套餐
        $packageLogic = model('common/package/PackageLogic', 'logic');
        $packageLogic->givePackage($member_id, $packageLogic::REAL_VERIFY_GIVE);



        return $res?ds_arr(SUCCESS, '认证通过', $res['result']):ds_arr(ERROR, '认证失败');

    }


    /**
     * User: Simony
     * Function:设置邀请码
     * @param $member_id
     * @param $invite_code
     * @return array
     */
    public function setInviteCode($member_id, $invite_code)
    {

        if (empty($invite_code)) return ds_arr(ERROR, '邀请码不能为空');

        $memberModel = model('common/member/Member');
        $member_invite_code = $memberModel->getVal('invite_code', ['id' => $member_id]);

        if (!empty($member_invite_code)) return ds_arr(ERROR, '该用户已存在邀请人，不需要重复填写');


        $inviteMember = $memberModel->getInfo(['invite_code' => $invite_code]);
        if (empty($inviteMember)) return ds_arr(ERROR, '邀请人不存在或邀请码失效');

        if ($inviteMember['status'] == 0) return ds_arr(ERROR, '邀请人被禁用');
        if ($inviteMember['is_company'] == 0 && $inviteMember['parent_id'] == 0) return ds_arr(ERROR, '邀请人无推荐人');

        $update_data = [
            'parent_id' => $inviteMember['id'],
            'recommend_dept' => $inviteMember['recommend_dept'] + 1,
            'recommend_str' => empty($inviteMember['recommend_str']) ? $member_id : $member_id . ',' . $inviteMember['recommend_str'],
            'invite_code' => $memberModel->createInviteCode()
        ];
        if ($inviteMember['type'] == 1) {
            $update_data['type'] = 2;
            $invite_update_res = $memberModel->editByID($inviteMember['id'], ['invite_code' => $memberModel->createInviteCode()]); //更新内部用户邀请码
            if (!$invite_update_res) return ds_arr(ERROR, '更新内部邀请码错误');
        }

        $update_res = $memberModel->editByID($member_id, $update_data);
        if (!$update_res) return ds_arr(ERROR, '邀请出错1');

        //更新推荐人的直推人数
        $res = $memberModel->setValIncByID($inviteMember['id'], 'recommend_num', 1);
        if (!$res) return ds_arr(ERROR, '邀请出错2');

        $packageLogic = model('common/package/PackageLogic', 'logic');
        $give_res = $packageLogic->givePackage($member_id, $packageLogic::REGISTER_GIVE);
        if ($give_res['code'] != SUCCESS) {
            Db::rollback();
            return ds_arr($give_res['code'], $give_res['msg']);
        }

        //设置邀请码发送通知
        $noticleLogic = model('common/Noticle', 'logic');
        $noticleLogic->sendAutoTxt($member_id, $noticleLogic::REGISTER_NOTICE);

        return ds_arr(SUCCESS, '操作成功');

    }


    /**
     * User: Simony
     * Function: 合伙人业绩
     * @param $member_id
     */
    public function partnerPerformance($member_id, $year)
    {
        $memberModel = model('common/member/Member');
        $parner = $memberModel->getInfo(['id' => $member_id, 'identity' => $memberModel::PARTNER]);
        if (empty($parner)) return ds_arr(ERROR, '该用户不是合伙人');

        $bonusModel = model('common/bonus/Bonus');
        $packageBuyLogModel = model('common/package/PackageBuyLog');

        $current_month = date('m');
        $m = date('Y') == $year ? ($current_month > 9 ?: $current_month - 1) : 12;

        $year_data = [];
        $down_ids = $memberModel->getCol('id', 'find_in_set(' . $member_id . ',recommend_str)', '');
        for ($i = intval($m); $i > 0; $i--) {
            $month_start_end_time = get_month_start_end_time($year . '-' . $i);
            $start_time = $month_start_end_time['start_time'];
            $end_time = $month_start_end_time['end_time'];
            $where = [
                ['partner_money', 'gt', 0], ['member_id', 'eq', $member_id], ['done', 'eq', 1],
                ['grant_time', 'gt', $start_time], ['grant_time', 'lt', $end_time],
            ];
            $performance = $bonusModel->getSum($where, 'partner_money');
            $where = [
                ['pay_time', 'gt', $start_time], ['pay_time', 'lt', $end_time],
                ['member_id', 'neq', $member_id], ['member_id', 'in', implode(',', $down_ids)]
            ];
            $consume_num = $packageBuyLogModel->where($where)->group('member_id')->count();

            $year_data[] = [
                'month' => $i,
                'performance' => $performance,
                'consume_num' => $consume_num
            ];
        }

        $total_performance = $bonusModel->getSum([['partner_money', 'gt', 0], ['member_id', 'eq', $member_id], ['done', 'eq', 1]], 'partner_money');
        $month_start_end_time = get_month_start_end_time($year . '-' . $current_month);
        $start_time = $month_start_end_time['start_time'];
        $end_time = $month_start_end_time['end_time'];

        $data = [
            'total_performance' => $total_performance,
            'current_month_performance' => $bonusModel->getSum([
                ['partner_money', 'gt', 0], ['member_id', 'eq', $member_id], ['done', 'eq', 1],
                ['grant_time', 'gt', $start_time], ['grant_time', 'lt', $end_time],
            ], 'partner_money'),
            'current_month_consume_num' => $packageBuyLogModel->where([
                ['pay_time', 'gt', $start_time], ['pay_time', 'lt', $end_time],
                ['member_id', 'neq', $member_id], ['member_id', 'in', implode(',', $down_ids)]
            ])->group('member_id')->count(),
            'invite_code' => $parner['invite_code'],
            'number' => count($down_ids) - 1,
            'year_data' => $year_data,
        ];

        return ds_arr(SUCCESS, '获取成功', $data);

    }
}
